package org.red_cross_service.controller;

import lombok.SneakyThrows;
import org.red_cross_service.common.anno.NoNeedToken;
import org.red_cross_service.common.response.Response;
import org.red_cross_service.domain.entity.VideoEntity;
import org.red_cross_service.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value ="/api/video")
@CrossOrigin
public class VideoController {

    @Autowired
    private VideoService videoService;

    @NoNeedToken
    @PostMapping("/list")
    public Response list(@RequestBody VideoEntity videoEntity) {
        return Response.success(videoService.list(videoEntity));
    }
    @NoNeedToken
    @PostMapping("/add")
    public Response add(@RequestBody VideoEntity videoEntity) {
        return Response.success(videoService.add(videoEntity));
    }
    @NoNeedToken
    @PostMapping("/delete")
    public Response delete(@RequestBody VideoEntity videoEntity) {
        return Response.success(videoService.delete(
                videoEntity.getVideoId()
        ));
    }
    @NoNeedToken
    @PostMapping("/update")
    public Response update(@RequestBody VideoEntity videoEntity) {
        return Response.success(videoService.update(videoEntity));
    }
    @NoNeedToken
    @PostMapping("/selectOne")
    public Response selectOne(@RequestBody VideoEntity videoEntity) {
        return Response.success(videoService.selectOne(videoEntity));
    }
}
